package com.suzhe.ymall.base.controller;


import com.suzhe.ymall.base.service.UploadServcice;
import com.suzhe.ymall.base.vo.ImageVo;
import com.suzhe.ymall.common.pojo.ApiResEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/base/upload")
public class UploadController {

    @Autowired
    private UploadServcice uploadServcice;

    @PostMapping("image")
    public ApiResEntity<ImageVo> uploadImage(@RequestParam("file") MultipartFile file,String id) {
        ImageVo imageVo = this.uploadServcice.upload(file);
        imageVo.setId(id);
        return ApiResEntity.ok(imageVo);
    }
}
